package com.doctor.ui;

import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.WindowManager;
import android.widget.LinearLayout.LayoutParams;

import com.doctor.adapter.ShowImageAdapter;
import com.doctor.view.DragImageView;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.assist.ImageLoadingListener;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.assist.ImageSize;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

public class DragImageActivity extends BaseActivity{

	/**
	 * 查看伸缩图片
	 */
	
	private int	window_width, window_height;
	private PhotoView dragImageView;
	private int	state_height;
	private String picPath;
	
	private PhotoViewAttacher mAttacher;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.drag_image_activity);

		WindowManager manager = getWindowManager();

		dragImageView = (PhotoView) findViewById(R.id.div_main);

		picPath=getIntent().getStringExtra(getResources().getString(R.string.uri));
		initImageLoader(this);
		ImageLoader.getInstance().displayImage(ShowImageAdapter.PREFIX + picPath, dragImageView);
		
		mAttacher=new PhotoViewAttacher(dragImageView);
		mAttacher.setMinScale(0.5f);
	}

	private void initImageLoader(Context context) {

		DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
		.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
		.cacheInMemory(false).cacheOnDisc(false)
		.build();

		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
		.threadPriority(Thread.NORM_PRIORITY).denyCacheImageMultipleSizesInMemory()
		.discCacheExtraOptions(window_width, window_height, CompressFormat.JPEG, 80, null)
		.tasksProcessingOrder(QueueProcessingType.LIFO)
		.defaultDisplayImageOptions(defaultOptions)
		.build();
		ImageLoader.getInstance().init(config);
	}	
	
	
	
}
